/**
 * @file codeforces/1700/b/main
 * @brief
 * @see
 * @author Ruiming Guo (guoruiming@stu.scu.edu.cn)
 * @copyright 2022
 * @date 2022/6/21 19:43:36
 **/

#include <iostream>
#include <vector>
#define rep(i, a, b) for (int(i) = (a); i < (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int N = 100010;
char s[N];
int t[N];
int main() {
  // High rating and good luck!
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    scanf("%d%s", &n, s);
    if (s[0] != '9') {
      for (int i = 0; i < n; ++i) putchar('9' - s[i] + '0');
      putchar('\n');
    } else {
      int now = 0;
      for (int i = n - 1; i >= 0; --i) {
        t[i] = 1 - now - (s[i] - '0');
        now = 0;
        if (t[i] < 0) t[i] += 10, now = 1;
      }
      for (int i = 0; i < n; ++i) printf("%d", t[i]);
      putchar('\n');
    }
  }
  return 0;
}
